﻿app.controller('myMenuController', ['$scope', 'menuService', '$ocLazyLoad', 'tabService', function ($scope, menuService, $ocLazyLoad, tabService) {
    $scope.menus = menuService.menus;
    $scope.click = function (elem) {
        //左边选中的菜单
        var selectMenu = menuService.selectMenuByID(elem.menu.id);
        var templateurlstr = menuService.GetTemplateUrlString(selectMenu.key);

        if (tabService.tabs.length > 0) {
            var parenttab;
            if (selectMenu.parent) {
                parenttab = tabService.getTabByMenuID(selectMenu.parent.id);
            }

            var selectTab = tabService.selectTabByMenuID(selectMenu.id);

            if (selectTab == null) {
                var item1 = new tabService.tabItem(selectMenu.key, selectMenu.value, true, selectMenu.isclose, selectMenu.id, parenttab,true, templateurlstr);
                tabService.addTab(item1);
            }
        } else if (selectMenu.ishide == false) {
            var item1 = new tabService.tabItem(selectMenu.key, selectMenu.value, true, selectMenu.isclose, selectMenu.id, null,true, templateurlstr);
            tabService.addTab(item1);
        }
    }
} ])
